﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Designer.Views.Util
{
    static class ValidateUtil
    {
        /// <summary>
        /// 
        /// 根据父容器的类型验证子空间类型是否符合
        /// 比如场景中只能添加区域组件
        /// </summary>
        /// <param name="container"></param>
        /// <param name="childType"></param>
        /// <returns></returns>
        public static bool ValidateChildForParent(CPPEI.Coolzon.UI.IPartContainer container, string childType)
        {
            if(container is Coolzon.UI.ScenePart)
            {
                if(string.Equals(childType,"Area", StringComparison.CurrentCultureIgnoreCase))
                {
                    return true;
                }
                return false;
            }
            return true;
        }

        /// <summary>
        /// 验证组件是否可以在父容器中被拖动位置
        /// </summary>
        /// <param name="child"></param>
        /// <returns></returns>
        public static bool ValidateCanMove(CPPEI.Coolzon.UI.Part child)
        {
            if(child is Coolzon.UI.ScenePart)
            {
                return false;
            }

            if (child.ParentPart != null)
            {
                Coolzon.UI.ScenePart scenePart = child.ParentPart as Coolzon.UI.ScenePart;
                //容器是场景，切设置为允许互换，然后组件
                if (scenePart != null && (scenePart.Metadata as Coolzon.Metadata.Scene).IsAllowSwapArea)
                {
                    return false;
                }
                return true;
            }
            return false;
        }

        /// <summary>
        /// 验证组件是否能被选中，场景组件不能被选中
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public static bool ValidateCanSeleted(CPPEI.Coolzon.UI.Part part)
        {
            //if(part is Coolzon.UI.ScenePart)
            //{
            //    return false;
            //}
            return true;
        }
    }
}
